import asyncio

async def work(id,t):
    print('Working...')
    await asyncio.sleep(t)
    print(f'Work {id} done')

def main():
    loop=asyncio.new_event_loop()
    asyncio.set_event_loop(loop)
    coroutines=[ work(i,i) for i in range(1,4) ]
    try:
        loop.run_until_complete(asyncio.gather(*coroutines))
    except KeyboardInterrupt:
        loop.stop()
        tasks=asyncio.Task.all_tasks()
        for i in tasks:
            print(f'Task cancel:{i}')
            print(f'Cancel status:{i.cancel()}')
    finally:
        loop.close()

main()
